package com.zhuxiang.test1;

/**
 * 编程统计字符串"ABCD123!@#$%ab"中大写字母、小写字母、数字、其它字符的个数并打印出来。
 */
public class Demo1 {
    public static void main(String[] args) {
        //定义字符串
        String str = "ABCD123!@#$%ab";
        //将字符串转化为字节数组
        byte[] bytes = str.getBytes();
        int big = 0;
        int small = 0;
        int num = 0;
        int other = 0;
        for (int i = 0; i < bytes.length; i++) {
            int temp = bytes[i];
            if (temp >= 65 && temp <=90){
                big++;
            }else if (temp >=97 && temp <= 122) {
                small++;
            }else if (temp >= 48 && temp <=57){
                num++;
            }else {
                other++;
            }
        }
        System.out.println("大写字母的个数："+big+
                            " ,小写字母的个数："+small+
                            " ,数字的个数："+num+
                            " ,其他字符的个数："+other);
    }
}
